const serviceSql=require('../service/service')

class serviceController{
    async service(ctx,next){
        let detail=await serviceSql.detail()
        detail.forEach((item)=>{
            let JSONdata=JSON.stringify(item.dipole).slice(3,JSON.stringify(item.dipole).length-3).split('"},{"')
            let list = JSONdata.map(ele=>{
                let data=ele.split('":"')
                let title=data[0]
                let answer=data[1]
                return {
                    title,
                    answer
                }
            })
            item.dipole=list
        })
        ctx.body=detail

        await next()
    }
}

module.exports=new serviceController()